From: Julian Sparber Date: Tue, 30 Jan 2024 17:04:36 +0000 (+0100) Subject: messageTray: Introduce singleton Source for system notifications X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~2^2~27 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3faf1caeadc73b41ec1c04670f9e07da66e43e8c;p=gnome-shell.git messageTray: Introduce singleton Source for system notifications This `Source` object should be used by all notifications created by GNOME Shell and eventually can also be used by extensions. Part-of: --- diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 479044a3a..a069f16d4 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1326,6 +1326,29 @@ export const MessageTray = GObject.registerClass({ } }); +let systemNotificationSource = null; + +/** + * The {Source} that should be used to send system notifications. + * + * @returns {Source} + */ +export function getSystemSource() { + if (!systemNotificationSource) { + systemNotificationSource = new Source({ + title: _('System'), + iconName: 'emblem-system-symbolic', + }); + + systemNotificationSource.connect('destroy', () => { + systemNotificationSource = null; + }); + Main.messageTray.add(systemNotificationSource); + } + + return systemNotificationSource; +} + export const SystemNotificationSource = GObject.registerClass( class SystemNotificationSource extends Source { constructor() {